Repository navigation
Conversation
The setup agent now gets its instructions and model from the ldcli-setup-agent AI Config on catfood. The CLI evaluates the config locally with the Go AI SDK, with the detected facts as context attributes, so targeting can give each kind of project its own instructions and model. When the config loads, its instructions decide the task, and the first message gives only the facts from setup. No SDK key is on the user's machine. The SDK gets the placeholder key ldcli-placeholder, and a loopback proxy adds the user's access token in LD-CLI-Token and forwards each request to the relay at /internal/ldcli-setup-agent/sdk under the user's base URI. The relay adds the real key. The proxy accepts requests only under a random path. The SDK client polls once, because setup reads the config once per run. A quick check before the SDK starts makes a refusal fall back at once, and it reads the environment ID from the relay. The CLI sets every SDK option in code, because the SDK reads LD_ variables that ldcli also uses, and it turns the SDK's logging off. If the user is not logged in, or the config cannot load, setup uses the built-in instructions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
atornsii
added this pull request to stack #902
October 20, 2026 15:48
This was referenced Oct 20, 2026
…to atorns/agent-4-ai-sdk-relay # Conflicts: # go.mod # go.sum
Author
|
Holding in Draft as I wait for the GO AI SDK to be released. As of now it is using a pseudo version. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds the Go AI SDK (
github.com/launchdarkly/go-ai-sdk, pinned to commit 6152dc9) and reads theldcli-setup-agentAI Config through the SDK relay in gonfalon. No SDK key is on the user's machine.How it works
127.0.0.1under a random path.ldcli-placeholder, and every SDK option points at the proxy. The CLI sets each option in code, because the SDK readsLD_variables that ldcli also uses.LD-CLI-Tokenand forwards to<base-uri>/internal/ldcli-setup-agent/sdk/.... The relay adds the real key. The header does not start withX-LD-, because gonfalon strips client headers with that prefix.A quick check before the SDK starts makes a refusal fall back at once (the Go SDK retries a refused stream until its timeout), and it reads the environment ID from the
LD-Setup-Agent-Environment-IDheader. The SDK's logging is off, so it does not break the wizard's screen. If the config cannot load, setup uses the built-in instructions.Testing
A test starts the real AI SDK through the proxy against a fake relay. Other tests cover the proxy (token header, path mapping, secret path, streaming), refusals and an unreachable relay (fallback in less than one second), the options, the context, and the provider mapping. The path was tested end to end against a local gonfalon with the relay stack (launchdarkly/gonfalon#75196 to #75199) and a catfood config.
Diagram
Blue boxes are new files, orange boxes are changed files, dashed boxes are files from an earlier PR, and purple boxes are outside ldcli. A solid arrow goes from the caller to the code that it calls. A dashed arrow shows data that moves without a direct call.
setup.gobuilds anAIConfigSourcefrom the base URI and the access token, gives it to the runner as its config source, and closes it after the command. When the runner starts, it callsResolve. The first call starts the proxy fromrelay_proxy.go, makes a quick check of the relay, and starts the AI SDK client with all its URIs on the proxy.Resolvethen callsInspectConfigforldcli-setup-agentand returns the instructions and model. The first message comes fromBuildFactsinprompt.go. If any step fails,Resolvereturns the built-in instructions.This PR plugs a new
ConfigSourceinto the runner from #894.opencode.gochanges only to use the task text from the config.Stack
This is one of six PRs for the
ldcli setupagent. Review and merge them in order, after #877 (Go 1.26):They replace #876 and #878.
🤖 Generated with Claude Code